var sqlMap = {
  // 用户
  users: {//users指代表名
	//是对应的增删改查语句
    add: 'insert into users values(?,?,?,?,?)',
	addYh: 'insert into users(uid,uname,upwd,tel,role) values(?,?,?,?,DEFAULT)',
	select:'select * from users where role = 0',
	selectOne:'select * from users where uid=?',
	login:'select * from users where uid=? and upwd=? and role=?',
	updateInfo:'update users set uname=?,upwd=?,tel=? where uid=?',
	deleteOne:'delete from users where uid=?'
  },
  type:{
  	  selectAll:'select * from type',
	  deleteOne:'delete from type where id=?',
	  selectOne:'select * from type where id=?',
	  selectName:'select * from type where typename = ?',
	  updateInfo:'update type set typename=? where id=?',
	  add: 'insert into type values(default,?)',
  },
  books:{
	  addNumber:'update books set number=number+? WHERE goodsname = ?',
	  editNumber:'update books set number=? WHERE goodsname = ?',
	  updateNumber:'update books set number=number-? WHERE id = ?',
	  updateInfo:'UPDATE books SET TYPE=?,goodsname=?,imgs=?,price=?,gtext=?,productiondate=?,number=?,lirun=? WHERE id=?',
	  selectOne:'select * from books where id=?',
	  add: 'INSERT INTO books VALUES(DEFAULT,?,?,?,?,?,?,?,?)',
	  selectPriceS:'select * from books ORDER BY price',
	  selectPriceJ:'select * from books ORDER BY price desc',
  	  selectName:'select * from books where goodsname like ?',
	  selectPrice:'select * from books where goodsname=?',
	  selectType:'select books.* from books left join type on books.type = type.id where books.type = ?',
	  selectAll:'SELECT books.*,type.typename FROM books LEFT JOIN TYPE ON books.type = type.id',
	  selectById:'select books.*,type.typename from books left join type on books.type = type.id  where books.id = ?',
	  deleteOne:'delete from books where id=?',
	  updatelirun:'update books set lirun=lirun+1 where id=?'
  },
  orders:{
	  updateInfo:'update orders set money=?,num=? where oid=?',
	  updatePingjia:'update orders set pingjia=1 where oid=?',
	  selectOne:'SELECT users.uname,users.uid,users.tel,books.id,books.goodsname,books.price,orders.oid,orders.num,orders.money FROM orders LEFT JOIN users ON orders.uid = users.uid LEFT JOIN books ON orders.gid = books.id where orders.oid = ?',
	  deleteOne:'delete from orders where oid=?',
  	  insertOrders:'INSERT INTO orders1 VALUES(?,?,?,now(),0,?)',
	  selectMyOrdes:'SELECT * FROM orders1 WHERE uid=? order by otime desc',
	  selectOrdes:'SELECT * FROM orders1  order by otime desc',
	  updateZt:'update orders1 set shzt=1 where oid=?',
	  updateZt2:'update orders1 set shzt=2 where oid=?'
  },
  ordersdesc:{
	  insert:'insert into ordersdesc values(default,?,?,?,?,default)',
	  selectOrdersUid:'select * from orderdesc where uid=?',
	  selectOrdersOid:'SELECT * FROM ordersdesc,books WHERE ordersdesc.gid=books.id and oid=?',
	  updateState:'update ordersdesc set pingjia=1 where oid=? and gid=?',
	  selectTu:'SELECT goodsname name,ifnull(COUNT(*),0) value FROM ordersdesc,books WHERE ordersdesc.gid=books.id GROUP BY gid'
	  
  },
  comments:{
	  selectById:'select * from comments where gid = ?',
	  insertComments:'insert into comments values(default,?,?,?,?,?,now())',
	  selectMyComments:'SELECT * FROM comments , books where comments.gid = books.id and comments.uid = ? order by ctime desc',
  },

  card:{
	  deleteAll:'delete from card where uid=?',
	  deleteOne:'delete from card where cid=?',
  	  add: 'insert into card values(default,?,default,?)',
	  selectAll:'select card.*,books.goodsname,books.price,books.imgs from card LEFT JOIN books ON card.gid = books.id where card.uid=?',
	  selectOne:'select * from card where gid=?',
	  updateNum:'update card set number=number+1 where cid=?'
  },
  lunbo:{
	  add:'insert into lunbo values(default,?)',
	  select:'select * from lunbo',
	  selectQT:'select * from lunbo order by lid desc limit 4',
	  deleteOne:'delete from lunbo where lid=?',
	  update:'update lunbo set img=? where lid=?'
  },
  dizhi:{
	  selectOne:'select * from dizhi where did=?',
	  selecUid:'select * from dizhi where uid=?',
	  add:'insert into dizhi values(default,?,?,?,?,?,?,?,0)'
  },
  shoucang:{
	  insert:'insert into shoucang values(default,?,?,now())',
	  selectOne:'select * from shoucang where uid=? and gid=?',
	  deleteOne:'delete from shoucang where sid=?',
	  selectUid:'SELECT * FROM shoucang,books WHERE shoucang.gid=books.id AND uid=? order by stime desc',
	  selectAll:'SELECT * FROM shoucang,books WHERE shoucang.gid=books.id order by stime desc'
  }
}

module.exports = sqlMap;